package com.zhhh.domain;
// Generated 2019-10-11 15:23:22 by Hibernate Tools 3.4.0.CR1

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * BMode generated by hbm2java
 */
@Entity
@Table(name = "b_mode")
public class BMode implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String modeCode;
	private String modeName;
	private String modeDesc;
	private Integer ver;
	private String url;

	private Set<BRole> roles = new HashSet<BRole>();

	private Set<BModeControl> modeControls = new HashSet<BModeControl>();

	public BMode() {
	}

	public BMode(String modeCode, String modeName, String modeDesc, Integer ver, String url) {
		this.modeCode = modeCode;
		this.modeName = modeName;
		this.modeDesc = modeDesc;
		this.ver = ver;
		this.url = url;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)

	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "mode_code", length = 40)
	public String getModeCode() {
		return this.modeCode;
	}

	public void setModeCode(String modeCode) {
		this.modeCode = modeCode;
	}

	@Column(name = "mode_name", length = 40)
	public String getModeName() {
		return this.modeName;
	}

	public void setModeName(String modeName) {
		this.modeName = modeName;
	}

	@Column(name = "mode_desc", length = 40)
	public String getModeDesc() {
		return this.modeDesc;
	}

	public void setModeDesc(String modeDesc) {
		this.modeDesc = modeDesc;
	}

	@Column(name = "ver")
	public Integer getVer() {
		return this.ver;
	}

	public void setVer(Integer ver) {
		this.ver = ver;
	}

	@Column(name = "url", length = 40)
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@ManyToMany(cascade = CascadeType.ALL, mappedBy = "modes", fetch = FetchType.LAZY)
	@JsonIgnore // 多对多 防止死循环
	public Set<BRole> getRoles() {
		return roles;
	}

	public void setRoles(Set<BRole> roles) {
		this.roles = roles;
	}

	@OneToMany
	@org.hibernate.annotations.ForeignKey(name="none")
	@JoinColumn(name="mode_code", referencedColumnName="mode_code")
	//@OneToMany(cascade = { CascadeType.ALL},fetch = FetchType.LAZY, mappedBy = "mode")
	public Set<BModeControl> getModeControls() {
		return modeControls;
	}

	public void setModeControls(Set<BModeControl> modeControls) {
		this.modeControls = modeControls;
	}

}
